struct OurStruct {
    color: vec4f,
    offset: vec2f,
};
struct OtherStruct{
    scale: vec2f,
};

struct Vertex {
    // 从顶点缓冲区获取顶点数据
    @location(0) position: vec2f,
};

struct VSoutput{
    @builtin(position) position: vec4f,
    @location(0) color: vec4f,
};

@group(0) @binding(0) var<storage, read> ourStructs: array<OurStruct>;
@group(0) @binding(1) var<storage, read> otherStructs: array<OtherStruct>;

@vertex fn vs(
    vert: Vertex,
    @builtin(instance_index) instanceIndex: u32
) -> VSoutput {

    let ourStruct = ourStructs[instanceIndex];
    let otherStruct = otherStructs[instanceIndex];

    var output: VSoutput;
    output.position = vec4f (vert.position * otherStruct.scale + ourStruct.offset, 0.0, 1.0);
    output.color = ourStruct.color;
    return output;
}

// 通过inner-stage变量传递
@fragment fn fs(input: VSoutput) -> @location(0) vec4f {
    return input.color;
}
